
import pyautogui
import pyperclip


class SendText:
    def __init__(self, show_origin, show_trans):
        self.last_id = ""
        self.show_origin = show_origin
        self.show_trans = show_trans
        pass

    def make_text(self, a, b):
        text = ''
        if self.show_origin:
            text += a + '\n'
        if self.show_trans:
            text += b + '\n'
        return text

    def push(self, id, a, b):
        if self.last_id != id:
            pyautogui.hotkey('ctrl', 'enter')

        self.last_id = id
        
        text = self.make_text(a, b)
        pyperclip.copy(text)
        pyautogui.hotkey('ctrl', 'a')
        pyautogui.hotkey('ctrl', 'v')
